﻿using pluginService;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using wpf.Model;
using wpf.Utils;
using wpf.ViewModel;
using static wpf.Utils.LPlugin;

namespace wpf
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            var loc = new Locator();
            loc.LPlugin.FlashPulginView += FlashPulginView;
            loc.LPlugin.FlashTextView += FlashTextView;
            this.DataContext = loc;
        }

        /// <summary>
        /// 解决子线程无法更新ui线程
        /// </summary>
        public void FlashPulginView(List<PluginViewModel> lPlugins)
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                this.pulginlist.ItemsSource = lPlugins;
            }));
        }

        public void FlashTextView(string msg)
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                this.reciTextBox.Text = msg;
            }));
        }

    }
}